<!--

    Copyright © 2016-2024 The Thingsboard Authors

    Licensed under the Apache License, Version 2.0 (the "License");
    you may not use this file except in compliance with the License.
    You may obtain a copy of the License at

        http://www.apache.org/licenses/LICENSE-2.0

    Unless required by applicable law or agreed to in writing, software
    distributed under the License is distributed on an "AS IS" BASIS,
    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    See the License for the specific language governing permissions and
    limitations under the License.

-->
<div class="tb-form-panel no-border no-padding padding-top" [formGroup]="brokerConfigFormGroup">
  <div class="tb-form-row column-xs" fxLayoutAlign="space-between center">
    <div class="fixed-title-width tb-required" translate>gateway.host</div>
    <div class="tb-flex no-gap">
      <mat-form-field class="tb-flex no-gap" appearance="outline" subscriptSizing="dynamic">
        <input matInput name="value" formControlName="host" placeholder="{{ 'gateway.set' | translate }}"/>
        <mat-icon matSuffix
                  matTooltipPosition="above"
                  matTooltipClass="tb-error-tooltip"
                  [matTooltip]="('gateway.host-required') | translate"
                  *ngIf="brokerConfigFormGroup.get('host').hasError('required')
                                           && brokerConfigFormGroup.get('host').touched"
                  class="tb-error">
          warning
        </mat-icon>
      </mat-form-field>
    </div>
  </div>
  <div class="tb-form-row column-xs" fxLayoutAlign="space-between center">
    <div class="fixed-title-width tb-required" translate>gateway.port</div>
    <div class="tb-flex no-gap">
      <mat-form-field class="tb-flex no-gap" appearance="outline" subscriptSizing="dynamic">
        <input matInput type="number" min="{{portLimits.MIN}}" max="{{portLimits.MAX}}"
               name="value" formControlName="port" placeholder="{{ 'gateway.set' | translate }}"/>
        <mat-icon matSuffix
                  matTooltipPosition="above"
                  matTooltipClass="tb-error-tooltip"
                  [matTooltip]="brokerConfigFormGroup.get('port') | getGatewayPortTooltip"
                  *ngIf="(brokerConfigFormGroup.get('port').hasError('required') ||
                                            brokerConfigFormGroup.get('port').hasError('min') ||
                                            brokerConfigFormGroup.get('port').hasError('max')) &&
                                            brokerConfigFormGroup.get('port').touched"
                  class="tb-error">
          warning
        </mat-icon>
      </mat-form-field>
    </div>
  </div>
  <div class="tb-form-row column-xs" fxLayoutAlign="space-between center">
    <div class="fixed-title-width" translate>gateway.mqtt-version</div>
    <div class="tb-flex no-gap">
      <mat-form-field class="tb-flex no-gap" appearance="outline" subscriptSizing="dynamic">
        <mat-select formControlName="version">
          <mat-option *ngFor="let version of mqttVersions" [value]="version.value">{{ version.name }}</mat-option>
        </mat-select>
      </mat-form-field>
    </div>
  </div>
  <div class="tb-form-row column-xs" fxLayoutAlign="space-between center">
    <div class="fixed-title-width" translate>gateway.client-id</div>
    <div class="tb-flex no-gap">
      <mat-form-field class="tb-flex no-gap" appearance="outline" subscriptSizing="dynamic">
        <input matInput name="value" formControlName="clientId" placeholder="{{ 'gateway.set' | translate }}"/>
        <button type="button"
                matSuffix
                mat-icon-button
                aria-label="Generate"
                matTooltip="{{ 'gateway.generate-client-id' | translate }}"
                matTooltipPosition="above"
                (click)="generate('clientId')"
                *ngIf="!brokerConfigFormGroup.get('clientId').value">
          <mat-icon>autorenew</mat-icon>
        </button>
      </mat-form-field>
    </div>
  </div>
  <tb-security-config formControlName="security">
  </tb-security-config>
</div>
